package com.yjhealth.libs.businessdemo.business;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;

import com.anlia.photofactory.result.ResultData;
import com.yjhealth.libs.businessdemo.R;
import com.yjhealth.libs.commonlib.base.activity.BaseActivity;
import com.yjhealth.libs.core.core.activity.CoreActivity;
import com.yjhealth.libs.core.utils.image.PhotoUtil;

public class DemoButtonActivity extends BaseActivity {
    private PhotoUtil photoUtil;

    private ImageView ivPic;
    private Button button;
    private RatingBar ratingBar;

    @Override
    protected void onRefreshView() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.businessdemo_activity_demo_button);
        initLayout();

        ivPic = findViewById(R.id.ivPic);
        button = findViewById(R.id.btn);
        ratingBar = findViewById(R.id.ratingBar);

        photoUtil = new PhotoUtil(activity, new PhotoUtil.OnPhotoResultListener() {
            @Override
            public void result(ResultData resultData) {
                if (resultData == null) {
                    return;
                }
//                ivPic.setImageBitmap(resultData.addScaleCompress(150,150).GetBitmap());
                ivPic.setImageURI(resultData.addScaleCompress(250,250).GetUri());
            }
        });

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                photoUtil.showPhotoDialog(true);
            }
        });

        ratingBar.setRating(40);
    }
}
